home *** CD-ROM | disk | FTP | other *** search
- unit ntc_server_tracking;
- {
- Copyright (C) 2004 - 2006 Andrew Sprott
-
- http://astronomy.crysania.co.uk
- astro@trefach.co.uk
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- }
-
- interface
-
- uses
- Windows,
- Messages,
- SysUtils,
- Variants,
- Classes,
- Graphics,
- Controls,
- Forms,
- Dialogs,
- StdCtrls,
- Buttons,
- ExtCtrls,
- inifiles,
-
- ntc_server_form;
-
- const
- default_deviation=0.1;
- default_rate=60;
- default_lunar_rate=57.9;
-
- type
- Tscope_tracking = class(tform)
- tracking_panel: TPanel;
- change_tracking_group: TGroupBox;
- increase_tracking_button: TBitBtn;
- preset_defaults_group: TGroupBox;
- lunar_tracking_button: TBitBtn;
- default_tracking_button: TBitBtn;
- lunar_tracking_label: TLabel;
- default_tracking_label: TLabel;
- decrease_tracking_button: TBitBtn;
- tracking_edit: TEdit;
-
- { form handling }
- procedure FormCreate(
- Sender: TObject);
-
- procedure form_close_query(
- Sender: TObject;
- var CanClose: Boolean);
-
- { configuration }
- procedure save_settings;
-
- procedure load_settings;
-
- procedure flip_buttons(
- toggle:boolean);
-
- { events }
- procedure FormShow(
- Sender:TObject);
-
- procedure adjust;
-
- procedure check_activate(
- Sender: TObject);
-
- procedure decrease_tracking_buttonClick(
- Sender: TObject);
-
- procedure increase_tracking_buttonClick(
- Sender: TObject);
-
- procedure lunar_tracking_buttonClick(
- Sender: TObject);
-
- procedure default_tracking_buttonClick(
- Sender: TObject);
-
- procedure tracking_editChange(
- Sender: TObject);
-
- private
- { Private declarations }
- default_tracking_rate,
- default_lunar_tracking_rate:double;
- tracking_rate,
- lunar_tracking_rate:double;
- lunar_tracking:boolean;
- public
- { Public declarations }
- can_track:boolean;
- tracks_by:double;
- { configuration }
- dimensions:dimensions_record;
-
- { events }
- procedure check_visible_and_show_hide(
- sender:tobject);
-
- procedure hide_form;
- procedure show_form;
- end;
-
- var
- scope_tracking:Tscope_tracking;
-
- implementation
-
- uses
- ntc_server_network,
- ntc_server_config;
-
- {$R *.dfm}
-
- { -------------
- form handling
- ------------- }
-
- procedure Tscope_tracking.FormCreate(Sender: TObject);
- begin
- default_tracking_rate:=default_rate;
- tracking_rate:=default_tracking_rate;
- default_lunar_tracking_rate:=default_lunar_rate;
- lunar_tracking_rate:=default_lunar_tracking_rate;
- tracking_edit.text:=floattostr(tracking_rate);
- lunar_tracking:=false;
- can_track:=false;
- tracks_by:=default_deviation;
- flip_buttons(false);
- load_settings;
- end;
-
- procedure tscope_tracking.form_close_query(
- Sender: TObject;
- var CanClose: Boolean);
- begin
- canclose:=false;
- visible:=false;
- with dimensions do
- begin
- form_top:=top;
- form_left:=left;
- end;
- end;
-
- { ---------
- utilities
- --------- }
-
- procedure Tscope_tracking.flip_buttons(
- toggle:boolean);
- begin
- if scope_config.scope_type=celestron_type then
- toggle:=false;
- change_tracking_group.enabled:=toggle;
- preset_defaults_group.enabled:=toggle;
- end;
-
- { -------------
- configuration
- ------------- }
-
- procedure tscope_tracking.load_settings;
- begin
- ini_file:=tinifile.create(application_path+'server.ini');
- with ini_file do
- begin
- tracks_by:=ReadFloat('tracking','tracks_by',default_deviation);
- default_tracking_rate:=ReadFloat(
- 'tracking','default_tracking_rate',default_rate);
- default_lunar_tracking_rate:=readfloat(
- 'tracking','default_lunar_tracking_rate',default_lunar_rate);
- { form }
- scope.get_dimensions(scope_tracking,@dimensions,'tracking',ini_file);
- left:=dimensions.form_left;
- top:=dimensions.form_top;
- visible:=readbool('tracking','visible',false);
- end;
- ini_file.free;
- end;
-
- procedure tscope_tracking.save_settings;
- begin
- with ini_file do
- begin
- writefloat('tracking','default_tracking_rate',default_tracking_rate);
- writefloat(
- 'tracking','default_lunar_tracking_rate',default_lunar_tracking_rate);
- writefloat('tracking','tracks_by',tracks_by);
- { form }
- scope.find_vdu(scope_tracking,@dimensions);
- scope.write_dimensions(@dimensions,left,top,'tracking',ini_file);
- writebool('tracking','visible',visible);
- end;
- end;
-
- { ------
- events
- ------ }
-
- procedure tscope_tracking.FormShow(
- Sender:TObject);
- begin
- with dimensions do
- begin
- top:=form_top;
- left:=form_left;
- end;
- end;
-
- procedure tscope_tracking.adjust;
- begin
- with dimensions do
- begin
- form_top:=trunc(form_top/last_screen_height*current_height);
- form_left:=trunc(form_left/last_screen_width*current_width);
- end;
- if visible then
- show;
- end;
-
- procedure tscope_tracking.check_visible_and_show_hide(
- sender:tobject);
- begin
- if visible then
- hide_form
- else
- show_form;
- scope.show_hide(sender,visible);
- end;
-
- procedure tscope_tracking.hide_form;
- begin
- with dimensions do
- begin
- form_top:=top;
- form_left:=left;
- end;
- Visible:=false;
- end;
-
- procedure tscope_tracking.show_form;
- begin
- Visible:=true;
- end;
-
- procedure Tscope_tracking.check_activate(
- Sender: TObject);
- begin
- scope.form_activate(scope_tracking,@dimensions);
- end;
-
- procedure Tscope_tracking.decrease_tracking_buttonClick(
- Sender: TObject);
- begin
- if scope_network.local_scope_control and
- (scope_network.send_message_check('decrease_tracking')>=[exit_ok]) then
- begin
- tracking_rate:=tracking_rate-default_deviation;
- tracking_edit.text:=floattostr(tracking_rate);
- end;
- end;
-
- procedure Tscope_tracking.increase_tracking_buttonClick(
- Sender: TObject);
- begin
- if scope_network.local_scope_control and
- (scope_network.send_message_check('increase_tracking')>=[exit_ok]) then
- begin
- tracking_rate:=tracking_rate+default_deviation;
- tracking_edit.text:=floattostr(tracking_rate);
- end;
- end;
-
- procedure Tscope_tracking.lunar_tracking_buttonClick(
- Sender: TObject);
- begin
- if scope_network.local_scope_control then
- begin
- scope_network.send_message_check('lunar_tracking');
- tracking_rate:=default_lunar_tracking_rate;
- tracking_edit.text:=floattostr(tracking_rate);
- end;
- end;
-
- procedure Tscope_tracking.default_tracking_buttonClick(
- Sender: TObject);
- begin
- if scope_network.local_scope_control then
- begin
- scope_network.send_message_check('default_tracking');
- tracking_rate:=default_tracking_rate;
- tracking_edit.text:=floattostr(tracking_rate);
- end;
- end;
-
- procedure Tscope_tracking.tracking_editChange(
- Sender: TObject);
- begin
- tracking_edit.text:=floattostr(tracking_rate);
- end;
-
- end.
-